from enum import Enum



class DirectionEnum(Enum):
    """
    Direction of order/trade/position.
    """
    LONG = "多"
    SHORT = "空"
    NET = "净"


class OffsetEnum(Enum):
    """
    Offset of order/trade.
    """
    NONE = ""
    OPEN = "开"
    CLOSE = "平"
    CLOSETODAY = "平今"
    CLOSEYESTERDAY = "平昨"


class OrderStatusEnum(Enum):
    SUBMITTING = ("提交中", True)
    NOTTRADED = ("未成交", True)
    PARTTRADED = ("部分成交", True)
    ALLTRADED = ("全部成交", False)
    CANCELLED = ("已撤销", False)
    REJECTED = ("拒单", False)

    def __init__(self, description, is_active):
        self._description = description
        self._is_active = is_active

    @property
    def description(self):
        return self._description

    @property
    def is_active(self):
        return self._is_active


class ProductEnum(Enum):
    """
    Product class.
    """
    EQUITY = "股票"
    FUTURES = "期货"
    OPTION = "期权"
    INDEX = "指数"
    FOREX = "外汇"
    SPOT = "现货"
    ETF = "ETF"
    BOND = "债券"
    WARRANT = "权证"
    SPREAD = "价差"
    FUND = "基金"
    CFD = "CFD"
    SWAP = "互换"


class OrderTypeEnum(Enum):
    """
    Order type.
    """
    LIMIT = "限价"
    MARKET = "市价"
    STOP = "STOP"
    FAK = "FAK"
    FOK = "FOK"
    RFQ = "询价"


class OptionTypeEnum(Enum):
    """
    Option type.
    """
    CALL = "看涨期权"
    PUT = "看跌期权"


class CurrencyEnum(Enum):
    """
    Currency.
    """
    USD = "USD"
    HKD = "HKD"
    CNY = "CNY"
    CAD = "CAD"


class IntervalEnum(Enum):
    """
    Interval of bar data.
    """
    ONE_MINUTE = "1m"
    FIVE_MINUTE = "5m"
    TEN_MINUTE = "10m"
    HALF_HOUR = "30m"
    HOURLY = "1h"
    DAILY = "1d"
    WEEKLY = "1w"
    TICK = "tick"
